<?php
/**
 * Created by PhpStorm.
 * User: liuwenjie
 * Date: 2019/09/09
 * Time: 17:24
 */

namespace search\controllers\marketDataAnalysis;

use business\elasticsearch\services\IndustryService;

class IndustryController extends BaseController
{

    public function actionIndustryData()
    {
        try {
            $params['categoryCode']    = $this->getParam('category_code');
            $beginRegCapital = (int)$this->getParam('begin_reg_capital');
            $params['beginRegCapital'] = $beginRegCapital > 0 ? $beginRegCapital : 0;
            $endRegCapital = $this->getParam('end_reg_capital');
            if($endRegCapital != 'all'){
                $params['endRegCapital'] = $endRegCapital > 0 ? (int)$endRegCapital : 0;
            }else{
                $params['endRegCapital'] = $endRegCapital;
            }
            $params['areaCode']        = $this->getParam('area_code');
            $params['cooperation']     = $this->getParam('cooperation');

            $params['page']              = (int)$this->getParam('page', 'get', 1);
            $params['pageSize']          = (int)$this->getParam('pageSize', 'get', 10);

            return $this->success((new IndustryService())->getIndustryData($params));
        } catch (\Exception $ex){
            \Yii::error('error request method ' . __METHOD__ . $ex->getMessage());
            return $this->error('', '获取失败，请稍后重试');
        }
    }


}